package com.itcast.cn;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/servletDemo5")
public class ServletDemo5 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            System.out.println("Demo5");
            request.setCharacterEncoding("utf-8");
            //在发送之前先设置数据
            request.setAttribute("HEHE","哈哈哈吃饭了");
            System.out.println("要发的数据是：哈哈哈吃饭了");
            //转发
            request.getRequestDispatcher("/servletDemo6").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
